<?php
/**
 * Created by PhpStorm.
 * User: zq
 * Date: 2018/2/9
 * Time: 00:47
 */

namespace Helper;
class Json
{

    public static function output($data = [], $code = 200, $msg = '')
    {
        header('Content-type:application/json');
        header('Access-Control-Allow-Credentials:true');
        header('Access-Control-Allow-Origin:*');

        $json = ErrorCode::info($code);
        if ($data) {
            $json['data'] = $data;
        }
        if ($msg) {
            $json['message'] = $msg;
        }

        echo json_encode($json);
        exit;
    }
}